home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_43_Vid slider.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  6.2 KB  |  168 lines

  1. property pDuration, pMovieTime, VideoSprite, horizontal, extentSprite, hiliteMember, normalMember, tracking, newLocH, newLocV, sending, dynamic, style, Addressee, name, notify_list, min, max, valrange, minScreen, maxScreen, currentScreenVal, extentlength, CurrentVal
  2.  
  3. on getPropertyDescriptionList
  4.   set description to [:]
  5.   if the currentSpriteNum = 0 then
  6.     set memdefault to 0
  7.   else
  8.     set memref to the member of sprite the currentSpriteNum
  9.     set castLibNum to the castLibNum of memref
  10.     set memdefault to member (the memberNum of member memref + 1) of castLib castLibNum
  11.   end if
  12.   addProp(description, #hiliteMember, [#default: memdefault, #format: #bitmap, #comment: "Pict for Down:"])
  13.   addProp(description, #VideoSprite, [#default: the currentSpriteNum + 5, #format: #integer, #comment: "Video Sprite:"])
  14.   addProp(description, #extentSprite, [#default: the currentSpriteNum - 5, #format: #integer, #comment: "Slder Constraint Sprite:"])
  15.   addProp(description, #horizontal, [#default: 1, #format: #boolean, #comment: "Horizontal (if not vertical):"])
  16.   addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
  17.   return description
  18. end
  19.  
  20. on getBehaviorDescription
  21.   return "Video Control Slider"
  22. end
  23.  
  24. on getAssocMembers
  25.   set myPropList to [hiliteMember]
  26.   return myPropList
  27. end
  28.  
  29. on compute_val me
  30.   set val to 0.0
  31.   set val to float(the currentScreenVal of me) / float(the extentlength of me)
  32.   set val to val * the valrange of me
  33.   set val to val + the min of me
  34.   return val
  35. end
  36.  
  37. on send_the_val me, val
  38.   set pMovieTime to val * pDuration
  39.   set the movieTime of sprite VideoSprite to pMovieTime
  40. end
  41.  
  42. on beginSprite me
  43.   global movieMe
  44.   set pDuration to the duration of sprite(VideoSprite)
  45.   set the min of me to 0.0
  46.   set the max of me to 1.0
  47.   set the sending of me to 1
  48.   set handle to the spriteNum of me
  49.   set the tracking of me to 0
  50.   set the newLocH of me to the locH of sprite handle
  51.   set the newLocV of me to the locV of sprite handle
  52.   if the horizontal of me then
  53.     set the newLocV of me to the locV of sprite the extentSprite of me
  54.     set the minScreen of me to the left of sprite the extentSprite of me
  55.     set the maxScreen of me to the right of sprite the extentSprite of me
  56.   else
  57.     set the newLocH of me to the locH of sprite the extentSprite of me
  58.     set the minScreen of me to the left of sprite the extentSprite of me
  59.     set the maxScreen of me to the right of sprite the extentSprite of me
  60.   end if
  61.   puppetSprite(handle, 1)
  62.   set the stretch of sprite handle to 0
  63.   set the locH of sprite handle to the newLocH of me
  64.   set the locV of sprite handle to the newLocV of me
  65.   set the valrange of me to the max of me - the min of me
  66.   set the extentlength of me to the maxScreen of me - the minScreen of me
  67.   if the sending of me = 0 then
  68.     set the dynamic of me to 0
  69.   end if
  70.   set the normalMember of me to the member of sprite the spriteNum of me
  71.   set movieMe to the movieRate of sprite the VideoSprite of me
  72. end
  73.  
  74. on endSprite me
  75.   puppetSprite(the spriteNum of me, 0)
  76. end
  77.  
  78. on exitFrame me
  79.   if tracking then
  80.     set handle to the spriteNum of me
  81.     set extent to the extentSprite of me
  82.     if the horizontal of me then
  83.       set the newLocH of me to the mouseH
  84.       set the newLocV of me to the locV of sprite extent
  85.       if the newLocH of me < the left of sprite extent then
  86.         set the newLocH of me to the left of sprite extent
  87.       end if
  88.       if the newLocH of me > the right of sprite extent then
  89.         set the newLocH of me to the right of sprite extent
  90.       end if
  91.       set the currentScreenVal of me to the newLocH of me - the minScreen of me
  92.     else
  93.       set the newLocH of me to the locH of sprite extent
  94.       set the newLocV of me to the mouseV
  95.       if the newLocV of me < the top of sprite extent then
  96.         set the newLocV of me to the top of sprite extent
  97.       end if
  98.       if the newLocV of me > the bottom of sprite extent then
  99.         set the newLocV of me to the bottom of sprite extent
  100.       end if
  101.       set the currentScreenVal of me to the newLocV of me - the minScreen of me
  102.     end if
  103.     set the locH of sprite handle to the newLocH of me
  104.     set the locV of sprite handle to the newLocV of me
  105.     if the dynamic of me then
  106.       send_the_val(me, compute_val(me))
  107.     end if
  108.   else
  109.     set x to float(the movieTime of sprite VideoSprite) / float(pDuration)
  110.     set handle to the spriteNum of me
  111.     set extent to the extentSprite of me
  112.     if the horizontal of me then
  113.       set ScreenX to the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
  114.       set the newLocH of me to ScreenX
  115.       set the newLocV of me to the locV of sprite extent
  116.       if the newLocH of me < the left of sprite extent then
  117.         set the newLocH of me to the left of sprite extent
  118.       end if
  119.       if the newLocH of me > the right of sprite extent then
  120.         set the newLocH of me to the right of sprite extent
  121.       end if
  122.       set the currentScreenVal of me to the newLocH of me - the minScreen of me
  123.     else
  124.       set ScreenY to the top of sprite extent + (x * (the bottom of sprite extent - the top of sprite extent))
  125.       set the newLocH of me to the locH of sprite extent
  126.       set the newLocV of me to ScreenY
  127.       if the newLocV of me < the top of sprite extent then
  128.         set the newLocV of me to the top of sprite extent
  129.       end if
  130.       if the newLocV of me > the bottom of sprite extent then
  131.         set the newLocV of me to the bottom of sprite extent
  132.       end if
  133.       set the currentScreenVal of me to the newLocV of me - the minScreen of me
  134.     end if
  135.     set the locH of sprite handle to the newLocH of me
  136.     set the locV of sprite handle to the newLocV of me
  137.   end if
  138. end
  139.  
  140. on mouseDown me
  141.   set tracking to 1
  142.   set the member of sprite the spriteNum of me to member the hiliteMember of me
  143. end
  144.  
  145. on mouseUp me
  146.   set tracking to 0
  147.   set the member of sprite the spriteNum of me to member the normalMember of me
  148.   if the sending of me then
  149.     set x to compute_val(me)
  150.     send_the_val(me, x)
  151.   end if
  152. end
  153.  
  154. on mouseUpOutSide me
  155.   set tracking to 0
  156.   set the member of sprite the spriteNum of me to member the normalMember of me
  157.   if the sending of me then
  158.     set x to compute_val(me)
  159.     send_the_val(me, x)
  160.   end if
  161. end
  162.  
  163. on mouseEnter me
  164. end
  165.  
  166. on mouseLeave me
  167. end
  168.